package top.ewind.controller.admin.data;

import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;

import top.ewind.controller.common.AdminRootCtrl;
import top.ewind.util.SecurityUtil;

public class DataCtrl   extends AdminRootCtrl {

	public void index() {
		render("index.html");
	}
	public void profile() {
		int nid = getSessionAttr("nid");
		String filter = " nid ="+nid+SecurityUtil.sqlFilter(getPara("param", ""));
		renderJson(Db.paginate(getParaToInt("page", 1), getParaToInt("rp", 10), "select * ", " from device_data where " + filter));
	}
	
	/*delete*/
	public void delete() {
		boolean ret = false;
		if(StrKit.notBlank(getPara("id"))){
			ret = Db.deleteById("device_data",getPara("id"));
		}
		if(StrKit.notBlank(getPara("ids"))){
			ret = Db.update("delete from device_data where id in ("+getPara("ids")+")")>0;
		}
		if (ret)
			renderJson("msg", "success");
		else
			renderJson("msg", "删除失败，请重试！");
	}
}
